#ifndef _MQTTCLIENT_DATACTRL_H_
#define _MQTTCLIENT_DATACTRL_H_

#include <QObject>
#include <QMap>
#include "PublicStruct.h"

class CSqliteProxy;

class CDataCtrl : public QObject
{
	Q_OBJECT
public:
	CDataCtrl(QObject *parent = nullptr);
	~CDataCtrl();
	const QMap<QString, CGroupOpt>& getGroups();
	const QMap<QString, QList<CConnectOpt>>& getConnects();

private slots:
	void slotInitDbData();
	void slotInsertGroup(QString strId, QString strName);
	void slotDeleteGroup(QString strId);
	void slotUpdateGroup(QString strId, QString strName);
	void slotInsertConnect(QString strGroupId, CConnectOpt opt);
	void slotDeleteConnect(QString strId);
	void slotUpdateConnect(CConnectOpt opt);

private:
	void initGroup();
	void initConnect();

private:
	QMap<QString, CGroupOpt> m_groups;
	QMap<QString, QList<CConnectOpt>> m_connects;
	CSqliteProxy *m_pSqlProxy;
};
#endif
